<%--
  Created by IntelliJ IDEA.
  User: Inch
  Date: 2020/9/28
  Time: 13:33
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Send Json</title>
    <script src="${pageContext.request.contextPath}/jquery/jquery-3.5.1.js"></script>
    <%--相对路径，推荐使用上面的--%>
<%--    <script src="/jquery/jquery-3.5.1.js"></script>--%>
</head>
<body>
    <input type="button" value="ajax" onclick="send_json();">
    <script>
        function send_json(){
            //ajax send json
            var user = {id:123, name:"spring", gender:true}
            var userJson = JSON.stringify(user);
            $.ajax({
                url:"${pageContext.request.contextPath}/json/test4",
                type:"post",
                data:userJson,
                contentType:"application/json",
                success:function(ret) {
                    alert(ret);
                }
            })
        }
    </script>

</body>
</html>
